<#include "../common/_layout.html"/>
<@layout>
<div class="ui-form ui-border-t">
    <form id="infoForm">
        <div class="ui-form-item ui-border-b">
            <label>标题 <font color="red">*</font></label>
            <input type="text" placeholder="标题 " name="info.title" value="${(info.title)!}" id="title">
            <input type="hidden" name="info.id" value="${(info.id)!}"/>
            <input type="hidden" name="info.type" value="4"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>类别<font color="red">*</font></label>
            <div class="ui-select">
	            <select name="info.category" id="category">
	            	<option value="0">请选择</option>
	            	<option value="户外游玩" <#if ((info.category)! == '户外游玩')> selected </#if> >户外游玩</option>
	            	<option value="聚会" <#if ((info.category)! == '聚会')> selected </#if> >聚会</option>
	            	<option value="活动" <#if ((info.category)! == '活动')> selected </#if> >活动</option>
	            </select>
	        </div>    
        </div>
        <div class="ui-form-item ui-form-item-textarea ui-border-b">
            <label>活动说明<font color="red">*</font></label>
            <textarea placeholder="活动说明" name="info.description" id="description">${(info.description)!}</textarea>
        </div>
		<div class="ui-form-item ui-border-b">
            <label>主办方</label>
            <input type="text" placeholder="主办方名称" name="info.company" value="${(info.company)!}" id="company"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>费用(元)</label>
            <input type="text" placeholder="免费" name="info.price" value="${(info.price)!}"/>
        </div>
        
        <div class="ui-form-item ui-border-b">
            <label>活动地址<font color="red">*</font></label>
            <input type="text" placeholder="活动详细地址" name="info.address" value="${(info.address)!}" id="address"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>联系人<font color="red">*</font></label>
            <input type="text" placeholder="联系人" name="info.contacts" value="${(info.contacts)!}" id="contacts"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>联系电话<font color="red">*</font></label>
            <input type="text" name="info.mobile" placeholder="联系电话" value="${(info.mobile)!}" id="mobile">
        </div>
        <div class="ui-form-item ui-border-b">
            <label>联系QQ</label>
            <input type="text" name="info.qq" placeholder="联系QQ" value="${(info.qq)!}" id="qq">
        </div>
        <div class="ui-form-item ui-border-b">
            <label>起始日期</label>
            <input type="text" placeholder="20150520" name="startDateStr" value="${(info.startDateStr)!}"/>
        </div>
        <div class="ui-form-item ui-border-b">
            <label>截止日期</label>
            <input type="text" placeholder="20150521" name="endDateStr" value="${(info.endDateStr)!}"/>
        </div>

       	 <div class="ui-btn-wrap">
                <input type="button" class="ui-btn-lg ui-btn-primary" id="savebtn" onclick="save();" value="发布"/>
            </div>
    </form>
</div>

<script type="text/javascript">
	function save(){
		if(!$("#title").val()){
			tips("请填写标题");
			return false;
		}
		
		if($("#category").val() == 0){
			tips("请选择类别");
			return false;
		}
		
		if(!$("#description").val()){
			tips("请完善活动说明");
			return false;
		}
		
		if(!$("#address").val()){
			tips("请填写活动地址");
			return false;
		}
		
		if(!$("#contacts").val()){
			tips("请填写联系人");
			return false;
		}
		
		if(!$("#mobile").val()){
			tips("请填写联系电话");
			return false;
		}
		
		$.ajax({
	         type: "post",
	         url: "info/save",
	         data:$("#infoForm").serialize(),// 要提交的表单 
	         success:function(data){
	        	  var msg = data.msg;
		          if(data.code==200){
		        	  msg = "发布成功";
		              setTimeout(function(){window.location.href='/my';},1000);
		          }
		          
		          $.tips({
		  				content:msg,
		  				stayTime:1000,
		  				type:"info"
		  			});
		       }
	    });
	}
</script>
</@layout>